//
//  MLDNavigationController.swift
//  Sina
//
//  Created by 万世豪情 on 15/10/13.
//  Copyright © 2015年 万世豪情. All rights reserved.
//

import UIKit

class MLDNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count>0 {
        
            var titleName = "返回"
        
        if childViewControllers.count == 1 {
        
            titleName = childViewControllers.first!.title!
        }
        //push后隐藏键盘
        viewController.hidesBottomBarWhenPushed = true
        viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.item("navigationbar_back_withtext", title: titleName, target: self, action:"back")
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func back(){
    
        popViewControllerAnimated(true)
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
